home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / programr / cxtw107.zip / SXTNVIEW.DOC < prev    next >
Text File  |  1995-07-20  |  17KB  |  428 lines

  1.  
  2.  
  3.         SXTNVIEW.DOC
  4.  
  5.         SXTNVIEW - SXTN Database Viewer Sample Application
  6.  
  7.         The SXTNVIEW program is  intended  as  a  sample  application  to
  8.         demonstrate  the use of the DLL interface functions to access the
  9.         SXT databases. Each SXT windows version provides its specific DLL
  10.         (CFTNWIN.DLL, CSTNWIN.DLL, ...) together with the necessary C/C++
  11.         header file (CFTNWIN.H,  CSTNWIN.H,  ...) and an  import  library
  12.         (CFTNWIN.LIB,  CSTNWIN.LIB,  ...)  that  can  be  linked  to your
  13.         programs. SXTNVIEW is a very simple application written in Visual
  14.         Basic with complete source code included. SXTNVIEW works with all
  15.         SXT DLL's and demonstrates the access to all SXT database types.
  16.  
  17.         To run SXTNVIEW,  the Visual Basic runtime  library  VBRUN300.DLL
  18.         (not  included  in this package) installed in the \windows\system
  19.         directory is required. It is also necessary to copy the SXT DLL's
  20.         to the \windows\system directory.
  21.  
  22.         After starting SXTNVIEW you have to select the SXT  program  type
  23.         and the database from the file dialog box.  Select one *.dbf file
  24.         that belongs to the project you want to view.  After that you can
  25.         view  in two list boxes the items (functions/data types),  either
  26.         all or only the defined ones,  and the filenames by pressing push
  27.         buttons  next  to these list boxes.  By a double click on an item
  28.         you get its location (filename, line number) where it is defined/
  29.         first found.  By a double click on a filename you get a  list  of
  30.         all  defined  items in that file.  You can also directly type the
  31.         name of an item into the 'Search for' text box and start a search
  32.         with the push button. If an itemname is in the search box you can
  33.         press the 'Get Called Item' button to retrieve  all  items  which
  34.         are called from the item.
  35.  
  36.         Any  running  action  can be safely stopped by pressing the 'Stop
  37.         Action' button. The system returns to default state.
  38.  
  39.  
  40.         DLL INTERFACE FUNCTIONS
  41.  
  42.         The following description  is  given  for  the  CFT  version  but
  43.         applies in the same  way to all other SXT programs.  The user who
  44.         calls one of these functions  has  to  ensure  that  the  calling
  45.         parameters  are  large  enough  to  hold the resulting value.  In
  46.         general,  the strings should be a minimum of 300 characters  long
  47.         (char location[300], char name[300], ...).
  48.  
  49.         Some  functionality  is  split into a pair of two closely related
  50.         functions,  like cftnGetFirstName()  and  cftnGetNextName().  The
  51.         user  has to ensure that they are called in a direct sequence and
  52.         that  there  are  no  intermediate   calls,   also   from   other
  53.         applications. Otherwise the results will be incorrect. The reason
  54.         for  the split of the functionality is that it is not possible to
  55.         determine the amount  of  memory  to  hold  the  results  of  the
  56.         function  call in advance by the calling function.  It would have
  57.         been possible  to  grow  the  memory  dynamically  during  search
  58.         operation by the DLL, return a pointer to the memory and leave it
  59.  
  60.  
  61.                                       - 1 -
  62.  
  63.  
  64.         to  the application to free it after use.  This would work with C
  65.         but not with Visual Basic or  application  macro  languages  like
  66.         Word Basic and Visual Basic for Applications.
  67.  
  68.         The return values of all DLL functions are 101 if successful, all
  69.         other  values  mean that something went wrong (e.g.  database not
  70.         found, database is not a SXT database,  item does not exist,  out
  71.         of memory, ...).
  72.  
  73.         Following is a description of the DLL-functions:
  74.  
  75.         LONG FAR PASCAL _export cftnGetLocation(LPSTR dbfname, LPSTR
  76.         name, LPSTR location);
  77.         Get the location of a specific item, if the return value is 101 a
  78.         location for item was found.
  79.              dbfname   the database name
  80.              name      the name of the item
  81.              location  contains a string with the location
  82.                        (filename<space>line number) of the item
  83.  
  84.         LONG FAR PASCAL _export cftnGetFirstName(LPSTR dbfname, LPSTR
  85.         name);
  86.         Get the first item from the database, must be called once before
  87.         cftnGetNextName.
  88.              dbfname   the database name
  89.              name      contains a string with the itemname
  90.  
  91.         LONG FAR PASCAL _export cftnGetNextName(LPSTR dbfname, LPSTR
  92.         name);
  93.         Get the next item from the database, must be called after
  94.         cftnGetFirstName, as long as the return value is 101 a new name
  95.         is retrieved.
  96.              dbfname   the database name
  97.              name      contains a string with the itemname
  98.  
  99.         LONG FAR PASCAL _export cftnGetFirstDefName(LPSTR dbfname, LPSTR
  100.         name);
  101.         Get the first defined item from the database, must be called once
  102.         before cftnGetNextDefName.
  103.              dbfname   the database name
  104.              name      contains a string with the defined itemname
  105.  
  106.         LONG FAR PASCAL _export cftnGetNextDefName(LPSTR dbfname, LPSTR
  107.         name);
  108.         Get the next defined item from the database, must be called after
  109.         cftnGetFirstDefName, as long as the return value is 101 a new
  110.         name is retrieved.
  111.              dbfname   the database name
  112.              name      contains a string with the defined itemname
  113.  
  114.         LONG FAR PASCAL _export cftnGetFirstCalledItem(LPSTR dbfname,
  115.         LPSTR caller, LPSTR calleditem, LPSTR location);
  116.         Get the first called item of caller from the database, must be
  117.         called once before cftnGetNextCalledItem.
  118.              dbfname        the database name
  119.              caller         contains a string with the name of the caller
  120.  
  121.  
  122.                                       - 2 -
  123.  
  124.  
  125.              calleditem     contains a string with the first called item
  126.              location       contains a string with the location
  127.                             (filename<space>line number) of the item
  128.  
  129.         LONG FAR PASCAL _export cftnGetNextCalledItem(LPSTR dbfname,
  130.         LPSTR caller, LPSTR calleditem, LPSTR location);
  131.         Get the next called item of caller from the database, must be
  132.         called after cftnGetFirstCalledItem, as long as the return value
  133.         is 101 a new called item is retrieved.
  134.              dbfname        the database name
  135.              caller         contains a string with the name of the caller
  136.              calleditem     contains a string with the first called item
  137.              location       contains a string with the location
  138.                             (filename<space>line number) of the item
  139.  
  140.         LONG FAR PASCAL _export cftnGetFirstFile(LPSTR dbfname, LPSTR
  141.         filename);
  142.         Get the first file from the database, must be called once before
  143.         cftnGetFirstFile.
  144.              dbfname   the database name
  145.              name      contains a string with the filename
  146.  
  147.         LONG FAR PASCAL _export cftnGetNextFile(LPSTR dbfname, LPSTR
  148.         filename);
  149.         Get the next file from the database, must be called after
  150.         cftnGetFirstFile, as long as the return value is 101 a new file
  151.         is retrieved.
  152.              dbfname   the database name
  153.              name      contains a string with the filename
  154.  
  155.  
  156.         THE VISUAL BASIC EXAMPLE 'SXTNVIEW'
  157.  
  158.         Following is a short, incomplete extract from the SXTNVIEW Visual
  159.         Basic source code to show some implementation details.
  160.  
  161.         1. DLL-FUNCTION DECLARATION
  162.         The DLL-functions have to be declared in the following way:
  163.  
  164.         Declare Function cftnGetLocation Lib "cftnwin.dll" (ByVal
  165.         dbfname$, ByVal searchname$, ByVal location$) As Long
  166.         Declare Function cftnGetFirstName Lib "cftnwin.dll" (ByVal
  167.         dbfname$, ByVal location$) As Long
  168.         Declare Function cftnGetNextName Lib "cftnwin.dll" (ByVal
  169.         dbfname$, ByVal location$) As Long
  170.         Declare Function cftnGetFirstDefName Lib "cftnwin.dll" (ByVal
  171.         dbfname$, ByVal location$) As Long
  172.         Declare Function cftnGetNextDefName Lib "cftnwin.dll" (ByVal
  173.         dbfname$, ByVal location$) As Long
  174.         Declare Function cftnGetFirstCalledItem Lib "cftnwin.dll" (ByVal
  175.         dbfname$, ByVal caller$, ByVal calleditem$, ByVal location$) As
  176.         Long
  177.         Declare Function cftnGetNextCalledItem Lib "cftnwin.dll" (ByVal
  178.         dbfname$, ByVal caller$, ByVal calleditem$, ByVal location$) As
  179.         Long
  180.  
  181.  
  182.  
  183.                                       - 3 -
  184.  
  185.  
  186.         Declare Function cftnGetFirstFile Lib "cftnwin.dll" (ByVal
  187.         dbfname$, ByVal location$) As Long
  188.         Declare Function cftnGetNextFile Lib "cftnwin.dll" (ByVal
  189.         dbfname$, ByVal location$) As Long
  190.         (similar for the other DLL's)
  191.  
  192.         2. CALLING THE RIGTH SXT FUNCTION
  193.         The  SXTNVIEW  functions  call  for every DLL-related function an
  194.         intermediate function where,  according to the selected SXT type,
  195.         the  right  DLL-function  is  called.  This simplifies the source
  196.         code.
  197.  
  198.         Function sxtnGetFirstName (dbfname$, location$) As Long
  199.           If option1.Value = True Then
  200.             sxtnGetFirstName = cftnGetFirstName(dbfname, location)
  201.           ElseIf option2.Value = True Then
  202.             sxtnGetFirstName = cstnGetFirstName(dbfname, location)
  203.           ElseIf option3.Value = True Then
  204.             sxtnGetFirstName = dftnGetFirstName(dbfname, location)
  205.           ElseIf option4.Value = True Then
  206.             sxtnGetFirstName = fftnGetFirstName(dbfname, location)
  207.           ElseIf option5.Value = True Then
  208.             sxtnGetFirstName = lftnGetFirstName(dbfname, location)
  209.           End If
  210.         End Function
  211.         (similar for the other SXT DLL functions)
  212.  
  213.         3. FUNCTION TO RETRIEVE THE LOCATION OF A SPECIFIC ITEM
  214.         Sub Command2_Click ()
  215.           Dim dbfname As String
  216.           Dim searchname As String
  217.           Dim result As String
  218.           result = String$(300, 0)
  219.           dbfname = label1.Caption
  220.           searchname = text1.Text
  221.           If Left(dbfname$, 1) <> "" And Left(searchname$, 1) <> "" Then
  222.             retval = sxtnGetLocation(dbfname$, searchname$, result$)
  223.             label7.Caption = result$
  224.           End If
  225.         End Sub
  226.  
  227.         4. FUNCTION TO RETRIEVE ALL FILES
  228.         Sub Command3_Click ()
  229.           Dim string1 As String
  230.           Dim result As String
  231.           string1$ = label1.Caption
  232.           result = String$(300, 0)
  233.           list2.Clear
  234.           If Left(string1$, 1) <> "" Then
  235.             retval = sxtnGetFirstFile(string1$, result$)
  236.             If retval = 101 Then
  237.               list2.AddItem result$
  238.               Do
  239.                 retval = sxtnGetNextFile(string1$, result$)
  240.                 If retval = 101 Then
  241.                   list2.AddItem result$
  242.  
  243.  
  244.                                       - 4 -
  245.  
  246.  
  247.                 Else
  248.                   Exit Do
  249.                 End If
  250.               Loop While retval = 101
  251.             End If
  252.           End If
  253.           label6.Caption = Str$(list2.ListCount) + " files"
  254.         End Sub
  255.  
  256.         5. FUNCTION TO RETRIEVE ALL ITEMS
  257.         Sub Command4_Click ()
  258.           Dim dbfname As String
  259.           Dim result As String
  260.           dbfname$ = label1.Caption
  261.           result = String$(300, 0)
  262.           list1.Clear
  263.           If Left(dbfname$, 1) <> "" Then
  264.             retval = sxtnGetFirstName(dbfname$, result$)
  265.             If retval = 101 Then
  266.               list1.AddItem result$
  267.               Do
  268.                 retval = sxtnGetNextName(dbfname$, result$)
  269.                 If retval = 101 Then
  270.                   list1.AddItem result$
  271.                 Else
  272.                   Exit Do
  273.                 End If
  274.               Loop While retval = 101
  275.             End If
  276.           End If
  277.           label5.Caption = Str$(list1.ListCount) + " items"
  278.         End Sub
  279.  
  280.         6. FUNCTION TO RETRIEVE ALL DEFINED ITEMS
  281.         Sub Command5_Click ()
  282.           Dim dbfname As String
  283.           Dim result As String
  284.           dbfname$ = label1.Caption
  285.           result = String$(300, 0)
  286.           list1.Clear
  287.           If Left(dbfname$, 1) <> "" Then
  288.             retval = sxtnGetFirstDefName(dbfname$, result$)
  289.             If retval = 101 Then
  290.               list1.AddItem result$
  291.               Do
  292.                 retval = sxtnGetNextDefName(dbfname$, result$)
  293.                 If retval = 101 Then
  294.                   list1.AddItem result$
  295.                 Else
  296.                   Exit Do
  297.                 End If
  298.               Loop While retval = 101
  299.             End If
  300.           End If
  301.           label5.Caption = Str$(list1.ListCount) + " defined items"
  302.         End Sub
  303.  
  304.  
  305.                                       - 5 -
  306.  
  307.  
  308.  
  309.         7. FUNCTION TO RETRIEVE ALL ITEMS DEFINED IN A SPECIFIC FILE
  310.         Sub List2_DblClick ()
  311.           Dim dbfname As String
  312.           Dim searchname As String
  313.           Dim result As String
  314.           dbfname$ = label1.Caption
  315.           result = String$(300, 0)
  316.           FileName = list2.List(list2.ListIndex)
  317.           list1.Clear
  318.           If Left(dbfname$, 1) <> "" Then
  319.             retval = sxtnGetFirstDefName(dbfname$, result$)
  320.             If retval = 101 Then
  321.               searchname = Left$(result, InStr(1, result, Chr$(0),1) - 1)
  322.               result = String$(300, 0)
  323.               retval = sxtnGetLocation(dbfname$, searchname$, result$)
  324.               If retval = 101 Then
  325.                 If InStr(1, result, FileName, 1) Then
  326.                   list1.AddItem searchname$
  327.                 End If
  328.               End If
  329.             End If
  330.  
  331.             Do
  332.               retval = sxtnGetNextDefName(dbfname$, result$)
  333.               If retval = 101 Then
  334.                 searchname = Left$(result, InStr(1, result, Chr$(0),1)-1)
  335.                 result = String$(300, 0)
  336.                 retval = sxtnGetLocation(dbfname$, searchname$, result$)
  337.                 If retval = 101 Then
  338.                   If InStr(1, result, FileName, 1) Then
  339.                     list1.AddItem searchname$
  340.                   End If
  341.                 End If
  342.               Else
  343.                 Exit Do
  344.               End If
  345.             Loop While retval = 101
  346.           End If
  347.           label5.Caption = Str$(list1.ListCount) + " defined items in "
  348.                                                  + FileName
  349.         End Sub
  350.  
  351.         8. FUNCTION TO RETRIEVE ALL CALLED ITEMS OF A SPECIFIC ITEM
  352.         Sub Command6_Click ()
  353.           Dim dbfname As String
  354.           Dim caller As String
  355.           Dim location As String
  356.           Dim calleditem As String
  357.           dbfname$ = label1.Caption
  358.           calleditem = String$(300, 0)
  359.           location = String$(300, 0)
  360.           caller = text1.Text
  361.           list1.Clear
  362.           If Left(dbfname$, 1) <> "" Then
  363.             retval = sxtnGetFirstCalledItem(dbfname$, caller$,
  364.  
  365.  
  366.                                       - 6 -
  367.  
  368.  
  369.                                             calleditem$, location$)
  370.             If retval = 101 Then
  371.               list1.AddItem calleditem$
  372.               Do
  373.                 retval = sxtnGetNextCalledItem(dbfname$, caller$,
  374.                                                calleditem$, location$)
  375.                 If retval = 101 Then
  376.                   list1.AddItem calleditem$
  377.                 Else
  378.                   Exit Do
  379.                 End If
  380.               Loop While retval = 101
  381.             End If
  382.           End If
  383.           label5.Caption = Str$(list1.ListCount) + " called items"
  384.         End Sub
  385.  
  386.  
  387.         FURTHER DEVELOPMENT
  388.  
  389.         The above example demonstrates the capabilites of the SXT-DLL's.
  390.         They can be called from any Windows application, e.g. MS Word for
  391.         Windows, MS Excel, MS Access, CodeWright Editor, or from user
  392.         developed applications.
  393.  
  394.  
  395.  
  396.         Copyright (C) Juergen Mueller (J.M.) 1988-1995.
  397.         All rights reserved world-wide.
  398.  
  399.         SXT (TM) SOFTWARE EXPLORATION TOOLS
  400.         SXTWIN (TM) SOFTWARE EXPLORATION TOOLS for Windows
  401.  
  402.  
  403.                            (THIS DOCUMENT HAS 7 PAGES)
  404.  
  405.  
  406.  
  407.  
  408.  
  409.  
  410.  
  411.  
  412.  
  413.  
  414.  
  415.  
  416.  
  417.  
  418.  
  419.  
  420.  
  421.  
  422.  
  423.  
  424.  
  425.  
  426.  
  427.                                       - 7 -
  428.